<!DOCTYPE html>
<html>
<head>
  <script src="../../processing.js"></script>
  <script src="../init.js"></script>
<link rel="stylesheet" href="../style.css"/></head>
<body><h1><a href="http://ejohn.org/blog/processingjs/">Processing.js</a></h1>
<h2>CreateImage</h2>

<p>Known to be broken. Needs a re-write of p.createImage(). <a href="https://processing-js.lighthouseapp.com/projects/41284-processingjs/tickets/243-createimage">Bug #243</p>

<p>The createImage() function provides a fresh buffer of pixels to play with.
This example creates an image gradient.</p>

<p><a href="http://processing.org/learning/basics/createimage.html"><b>Original Processing.org Example:</b> CreateImage</a><br>
<script type="application/processing">
PImage img;

void setup() 
{
  size( 200, 200 );  
  img = createImage( 120, 120, RGB );
  for(int i=0; i < img.pixels.length; i++) {
    img.pixels[i] = color(0, 90, 102, i%img.width * 2); 
  }
}

void draw() 
{
  background(204);
  image(img, 33, 33);
  //image(img, mouseX-60, mouseY-60);
  
  exit();
}
</script><canvas width="200" height="200"></canvas></p>
<div style="height:0px;width:0px;overflow:hidden;"><img src='data/mask.jpg' id='mask.jpg'/><img src='data/test.jpg' id='test.jpg'/></div>

<pre><b>// All Examples Written by <a href="http://reas.com/">Casey Reas</a> and <a href="http://benfry.com/">Ben Fry</a>
// unless otherwise stated.</b>
PImage img;

void setup() 
{
  size(200, 200);  
  img = createImage(120, 120, RGB);
  for(int i=0; i &lt; img.pixels.length; i++) {
    img.pixels[i] = color(0, 90, 102, i%img.width * 2); 
  }
}

void draw() 
{
  background(204);
  image(img, 33, 33);
  image(img, mouseX-60, mouseY-60);
}</pre>
</body>
</html>
